# -*- coding: utf-8 -*-
# Python 计算字典值之和

# 给定一个字典，然后计算它们所有数字值的和。
def returnSum(myDict):
    sum = 0
    for i in myDict:
        sum += myDict[i]

    return sum

dict = {'a':100, 'b':200, 'c':300}
print("sum:", returnSum(dict))

from functools import reduce

dict = {'a':100, 'b':200, 'c':300}
print('sum:', reduce(lambda x, y: x + y, dict.values()))